package com.gareve.twoSides.models;

import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.Vector2;
import com.gareve.twoSides.GameConstants;

public class ObstacleGenerator extends GameObject{
	public static final float WIDTH = GameConstants.SCREEN_WIDTH * 0.01f;
	public static final float HEIGHT = GameConstants.SCREEN_HEIGHT * 0.9f;

	public ObstacleGenerator(float x, float y){
		super(x, y,WIDTH,HEIGHT);
	}
	
	public void render(ShapeRenderer shapeRenderer){
		shapeRenderer.begin(ShapeType.Rectangle);
			shapeRenderer.setColor(1f, 1f, 1f, 1f);
			shapeRenderer.rect(shape.x, shape.y, shape.width, shape.height);
		shapeRenderer.end();
	}

	public Obstacle generateObstacle() {
		float x = shape.x;
		float y = (float) (shape.y + Math.random() * HEIGHT);
		Vector2 speed = new Vector2(GameConstants.OBSTACLE_MOVE_SPEED,0f);
		
		if(Math.random() <= 0.5f){//left
			speed.x = -speed.x;
		}else{
			x += WIDTH;
		}

		Obstacle obstacle = new Obstacle(x, y, speed);
		return obstacle;
	}
	
	public Vector2 getPoint1(){
		return new Vector2(shape.x, shape.y);
	}
	
	public Vector2 getPoint2(){
		return new Vector2(shape.x, shape.y + HEIGHT);
	}
}
